<?php @session_start();?>
<?php 
include_once './util/ArrayList.php';
include_once './util/db/model/Product.php';
include_once './util/db/model/ProdType.php';
include_once './util/db/model/ProdAttr.php';
include_once './util/db/model/ProdSubType.php';
include_once './util/db/model/SupplierBrand.php';
include_once './util/db/model/ProductSearchPara.php';
include_once './util/db/service/ProductDBUtil.php';
include_once './util/db/service/ProdAttrDBUtil.php';
include_once './util/db/service/OrderListDBUtil.php';
include_once './util/db/service/ProdTypeDBUtil.php';
include_once './util/db/service/SupplierBrandDBUtil.php';
include_once './util/db/service/PreorderListDBUtil.php';

//$p_id = $_GET["p_id"];
//$sb_id = $_GET["sb_id"];
$pd_id = $_GET["pd_id"];
$preorderListDBUtil = new PreorderListDBUtil();
if(isset($_GET["accept"])&& $_GET["accept"]=="true" && isset($_GET["pd_id"])){
	$preorderListDBUtil->acceptPreorderDetail($pd_id);
}
$orderListSearchPara = new OrderListSearchPara();
//$orderListSearchPara->setP_id($p_id);
//$orderListSearchPara->setSb_id($sb_id);
//$orderListSearchPara->setStatus("0"); //尋找商品是預購的
$orderListSearchPara->setPd_id($pd_id);

$preorderDetailArray = $preorderListDBUtil->queryPreorderDetail($orderListSearchPara);
$preorderDetail = $preorderDetailArray->get(0);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/supplier.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>預購商品出貨管理</title>
<!-- InstanceEndEditable -->
<style type="text/css">
<!--
#cantainer {
	width: 955px;
	margin-right: 33px;
	margin-left: 33px;
}
#header {
	width: 955px;
	margin-bottom: 10px;
	background-image: url(../../images/top_bg.png);
	height: 82px;
}
#body {
	width: 955px;
	margin-bottom: 10px;
}
#footer {
	width: 955px;
}
.style2 {color: #666666;
	font-size: 12px;
}
#contant_list {
	float: left;
	width: 180px;
	margin-right: 10px;
}
.style17 {color: #74B9E5; font-size: 14px; }
.style43 {font-size: 12px; color: #666666; font-weight: bold; }
#contant_body {
	float: right;
	width: 765px;
}
-->
</style>
<!-- InstanceBeginEditable name="head" -->
<style type="text/css">
<!--
#contant_body_header {
	background-image: url(../img/supplier_orderper_header.png);
	height: 62px;
	width: 765px;
	margin-bottom: 10px;
}
#contant_body_body {
	width: 765px;
	margin-bottom: 10px;
}
.style4 {font-size: 12px}
#contant_body_1_1 {width: 737px;
	margin-right: 10px;
	margin-bottom: 10px;
	margin-left: 10px;
}
#contant_body_1_2 {
	width: 737px;
	margin-right: 10px;
	margin-bottom: 10px;
	margin-left: 10px;
	height: 25px;
	background-image: url(../../admin/images/admin_order_productinfor_text.png);
}
#contant_body_1_3 {	width: 737px;
	margin-right: 10px;
	margin-bottom: 10px;
	margin-left: 10px;
}
#contant_body_1_6 {	width: 737px;
	margin-right: 10px;
	margin-bottom: 10px;
	margin-left: 10px;
}
#contant_body_1_text {
	height: 25px;
	width: 737px;
	margin-right: 10px;
	margin-bottom: 10px;
	margin-left: 10px;
	background-image: url(../../admin/images/admin_order_text.png);
}
-->
</style>
<!-- InstanceEndEditable -->
</head>

<body>
<table width="1024" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><div id="cantainer">
      <div id="header"></div>
      <div id="body">
       <div id="contant_list">
        <?php include_once './template/Category.php';?>
        </div>
        <!-- InstanceBeginEditable name="EditRegion1" -->
        <div id="contant_body">
          <div id="contant_body_header"></div>
          <div id="contant_body_body">
            <table cellpadding="0" cellspacing="0">
              <tr>
                <td colspan="3"><img src="../../member/img/member_body_up.jpg" width="765" height="9" /></td>
              </tr>
              <tr>
                <td width="4" background="../../member/img/member_body_left.jpg">&nbsp;</td>
                <td width="757"><div id="contant_body_1_text"></div>
                    <div id="contant_body_1_1">
                      <table width="737" cellspacing="0" cellpadding="5">
                        <tr>
                          <td width="100" class="style4">訂單日期</td>
                          <td class="style4"><?php echo $preorderDetail->getPreorderList()->getPreorder_date();?></td>
                        </tr>
                        <tr>
                          <td bgcolor="#D8F6F3" class="style4">訂單號碼</td>
                          <td bgcolor="#D8F6F3" class="style4"><?php echo $preorderDetail->getPreorderList()->getPreorder_no()?></td>
                        </tr>
                        <tr>
                          <td class="style4">收件人</td>
                          <td class="style4"><?php echo $preorderDetail->getPreorderList()->getPm_name();?></td>
                        </tr>
                        <tr>
                          <td bgcolor="#D8F6F3" class="style4">配送地址</td>
                          <td bgcolor="#D8F6F3" class="style4"><?php echo $preorderDetail->getPreorderList()->getPm_addr();?></td>
                        </tr>
                        <tr>
                          <td class="style4">連絡電話</td>
                          <td class="style4"><?php echo $preorderDetail->getPreorderList()->getPm_tel();?></td>
                        </tr>
                      </table>
                    </div>
                  <div id="contant_body_1_2"></div>
                  <div id="contant_body_1_3">
                      <table width="737" cellspacing="0" cellpadding="5">
                        <tr>
                          <td align="center" bgcolor="#CCCCCC" class="style4">商品號碼</td>
                          <td align="center" bgcolor="#CCCCCC" class="style4"><p>商品名稱</p></td>
                          <td align="center" bgcolor="#CCCCCC" class="style4">販售方式</td>
                          <td align="center" bgcolor="#CCCCCC" class="style4">商品尺吋</td>
                          <td align="center" bgcolor="#CCCCCC" class="style4">商品數量</td>
                          <td align="center" bgcolor="#CCCCCC" class="style4">金額</td>
                          <td align="center" bgcolor="#CCCCCC" class="style4">貨品狀況</td>
                        </tr>
							<tr>
								<td width="86" align="center"></td>
							</tr>
                        <tr>
                          <td colspan="7" class="style4"><table width="729" cellspacing="0" cellpadding="5">
                              <tr>
								<td width="90" align="center"><?php echo $preorderDetail->getProduct()->getProd_no()?></td>
								<td width="96" align="center"><?php echo $preorderDetail->getProduct()->getP_name()?></td>
								<td width="97" align="center"><?php echo $preorderDetail->getProduct()->getSell_mode()?></td>
								<td width="96" align="center"><?php echo $preorderDetail->getProdAttr()->getAttr();?></td>
								<td width="96" align="center"><?php echo $preorderDetail->getCount();?></td>
								<td width="96" align="center">NT$<?php echo number_format($preorderDetail->getPrice()*$preorderDetail->getCount())?></td>
                                <td width="86" align="center"><form id="form2" name="form2" method="post" action="">
                                  <?php if($preorderDetail->getProdAttr()->getCount()<=0){
									echo "缺貨";
								}else if($preorderDetail->getProdAttr()->getCount()>=10){
									echo "貨源充足";
								}else{
									echo "貨源不足";
								}?>
                                </form>
                                </td>
                              </tr>
                              
                            </table>
                            </td>
                        </tr>
                      </table>
                  </div>
                  <div id="contant_body_1_6">
                      <table width="737" cellspacing="0" cellpadding="5">
                        <tr>
                          <td align="center"><form id="form1" name="form1" method="post" action="">
                              <label>
							<?php if($preorderDetail->getStatus()==0){?>
							<input type="button" name="accept" id="accept_id" onclick="if(confirm('請問是否確定要出貨？')){top.location.href=top.location.href+'&accept=true&pd_id=<?php echo $pd_id?>';}" value="出貨" />
							<?php }?> 
                              <input type="submit" name="button" id="button" value="回上一頁" />
                              </label>
                          </form></td>
                        </tr>
                      </table>
                  </div></td>
                <td width="4" background="../../member/img/member_body_right.jpg">&nbsp;</td>
              </tr>
              <tr>
                <td height="9" colspan="3"><img src="../../member/img/member_body_down.jpg" width="765" height="9" /></td>
              </tr>
            </table>
          </div>
        </div>
        <!-- InstanceEndEditable --></div>
      <div id="footer">
         <?php include_once './template/footer.php';?>
      </div>

      </div></td>
  </tr>
</table>
</body>
<!-- InstanceEnd --></html>
